// pages/index/index.js

Page({
  data:{
    categoryId:1,
    
  },
   //分享功能
   onShareAppMessage:function(){
    return {
      title: '油菜花',
      desc: '油菜花',
      path: '/page/majar/majar_type'
    }
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    console.log("进入======");
    this.loadMajorTypes({ pageNum: 1, pageSize: 10 });
  
  },
  
  onReady:function(){
    // 页面渲染完成
   
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },
  openMajorList: function (e){
    
    wx.navigateTo({
      url: './majar_list?majartypeId=' + e.currentTarget.dataset.majartypeid,
    })
    
    
  },
  loadMajorTypes: function (requestObj) {
    var self = this;
    wx.request({
      url: getApp().globalData.server + "/major/major_category_list.do",
      data: requestObj,
      header: {
        'Content-Type': 'application/json'
      },
      success: function (res) {
        if (res.data.status != 0) {
          wx.showToast({
            title: res.data.msg,
            icon: 'none',
            duration: 1000,
            mask: true
          })
        } else {
          console.log(requestObj);
          console.log(res.data);
          self.setData({
            majorTypes: res.data.data.list,
          });
        }

      },
      fail: function () {
        wx.showToast({
          title: "获取专业类别失败",
          icon: 'none',
          duration: 1000,
          mask: true
        })
      }
    })
  }
})